import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart'hide Action;
import 'package:school_safe_teacher/resourse/app_colors.dart';


import 'action.dart';
import 'state.dart';

Reducer<ChangeUserInfoState> buildReducer() {
  return asReducer(
    <Object, Reducer<ChangeUserInfoState>>{
      ChangeUserInfoAction.action: _onAction,
    },
  );
}

ChangeUserInfoState _onAction(ChangeUserInfoState state, Action action) {
  final ChangeUserInfoState newState = state.clone();
  if (newState.info.isNotEmpty) {
    newState
      ..loginTextColor = Colors.white
      ..loginBtnStartColor = AppColors.loginLeft
      ..loginBtnEndColor = AppColors.loginRight;
  } else {
    newState
      ..loginTextColor = AppColors.cantClickTextColor
      ..loginBtnStartColor = AppColors.loginBtnColor
      ..loginBtnEndColor = AppColors.loginBtnColor;
  }
  return newState;
}
